# 加载环境
gcc_env=/usr/local/arm/arm64/environment-setup-aarch64-poky-linux
source $gcc_env

# 需要编译的APP名称
amp_test_app_names=(amp_echo_test amp_rsponse_test amp_rsponse_test_none_notify amp_rsponse_test_notify_none_deal)

for amp_test_app_name in ${amp_test_app_names[@]}
do

echo "prepare compile $amp_test_app_name"

set +e
rm $amp_test_app_name
set -e

# 编译命令
aarch64-poky-linux-gcc \
    -mtune=cortex-a55 -fstack-protector-strong -D_FORTIFY_SOURCE=2 \
    -Wformat -Wformat-security -Werror=format-security \
    --sysroot=/usr/local/arm/arm64/sysroots/aarch64-poky-linux \
     -pthread -Wall -O2 -g -DCFG_CA5X \
    -o $amp_test_app_name \
    ../src/channel.c \
    ../src/client.c \
    ../src/config.c \
    ../src/msgqueue.c \
    ../src/msg.c \
    ../src/shm.c \
    ../src/spinlock.c \
    $amp_test_app_name.c
    
# 修改执行权限
sudo chmod 755 $amp_test_app_name

set +e
sudo rm /media/ubuntu/RZ_ext/home/root/amp/$amp_test_app_name
set -e

sudo mv $amp_test_app_name /media/ubuntu/RZ_ext/home/root/amp/

echo "compile $amp_test_app_name success"
done

sudo cp amp_test.sh /media/ubuntu/RZ_ext/home/root/amp/

echo "mv amp_test.sh success"